<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>glTF Sample Viewer</title>

    <meta name="author" content="Khronos Group Inc.">
    <meta name="description" content="The official glTF sample viewer">
    <meta name="keywords" content="glTF, WebGL, Sample, Viewer, PBR">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="stylesheet" href="styles.css">
    <link rel="icon" href="assets/images/gltf.png">

    <script src="libs/dat.gui.min.js"></script>
    <script src="libs/stats.min.js"></script>

    <script src="dist/gltf-reference-viewer.umd.js"></script>
</head>

<script>
    // In renderer process (web page).
    const {ipcRenderer} = require('electron');
    var path = require('path');

    let remote = require('electron').remote,
      args = remote.getGlobal('sharedObject').args;

    function startRenderer()
    {
        let viewer = gltf_rv.gltf_rv(
            'canvas',
            'assets/models/2.0/model-index.json',
            args.environment,
            true,
            rendererReady);

        var gltfPath = path.parse(args.gltf_path)

        viewer.loadFromPath("/" + gltfPath.base, gltfPath.dir).then(() =>
        {
            const yfov_rad = args.yfov * Math.PI / 180.0;
            viewer.setCamera(
                args.eye_position,
                args.target_position,
                args.up,
                args.projection,
                args.znear,
                args.zfar,
                yfov_rad,
                args.size[0],
                args.size[1]);
            viewer.renderingParameters.cameraIndex = args.camera_index;
            viewer.setAnimation(args.animationIndex, args.animationTimeSec);
        });
    }

    function rendererReady()
    {
        ipcRenderer.send('rendererReady');
    }
</script>

<!-- Just create a rendering canvas like below and call gltf_rv! -->
<body onload="startRenderer();">
    <div id="gltf-rv-model-spinner"> </div>
    <canvas id="canvas">No Canvas!</canvas>
</body>



</html>
